package utils;

import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author : orangeCy.奕
 * @Product : 猎豹养成产品源码
 * @Time : 2021/12/19
 * @Desc :公共工具类
 */
public class CommonUtils {

    public static final String SEPARATE1 = ",";

    public static final String SEPARATE2 = ";";

    public static final String SEPARATE3 = "-";

    private CommonUtils() {
    }

    /**
     * @param textCons    "hello,{name} 你好"
     * @param repTemplate name
     * @param repValue    小奕
     * @return "hello,小奕 你好"
     */
    public static String adaptText(String textCons, String repTemplate, String repValue) {
        if (StringUtils.isBlank(textCons) || StringUtils.isBlank(repTemplate) || StringUtils.isBlank(repValue)) {
            return "";
        }
        String template = "{" + repTemplate + "}";
        return textCons.replace(template, repValue);
    }

    /**
     * 分隔符分割字符串转List
     * @param sourceStr
     * @param split
     * @return
     */
    public static List<String> strTransStringList(String sourceStr,String split) {
        if(StringUtils.isEmpty(sourceStr) || StringUtils.isEmpty(split)) {
            return Lists.newArrayList();
        }
        return new ArrayList<>(Lists.newArrayList(sourceStr.split(split)));
    }
}